<include file="public@header"/>
<style>
    .table img{
        width:25px;
        height:25px;
    }

    #pop{
        display:none;
    }

    .red_title{
        color: #F00;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>{:lang('USER_INDEXADMIN_INDEX')}</a></li>
        <li><a href="{:url('adminIndex/add')}">{:lang('ADD')}</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('user/adminIndex/index')}">

        僵尸粉开关：
        <select class="form-control" name="iszombie">
            <option value="">全部</option>
            <option value="1" <if condition="input('request.iszombie') neq '' && input('request.iszombie') eq 1">selected</if>>开启</option>
            <option value="0" <if condition="input('request.iszombie') neq '' && input('request.iszombie') eq 0">selected</if>>关闭</option>
        </select>
        僵尸粉：
        <select class="form-control" name="iszombiep">
            <option value="">全部</option>
            <option value="1" <if condition="input('request.iszombiep') neq '' && input('request.iszombiep') eq 1">selected</if>>是</option>
            <option value="0" <if condition="input('request.iszombiep') neq '' && input('request.iszombiep') eq 0">selected</if>>否</option>
        </select>

        拉黑：
        <select class="form-control" name="isban">
            <option value="">全部</option>
            <option value="1" <if condition="input('request.isban') neq '' && input('request.isban') eq 1">selected</if>>是</option>
            <option value="0" <if condition="input('request.isban') neq '' && input('request.isban') eq 0">selected</if>>否</option>
        </select>

        禁用：
        <select class="form-control" name="disable">
            <option value="">全部</option>
            <option value="1" <if condition="input('request.disable') neq '' && input('request.disable') eq 1">selected</if>>是</option>
            <option value="0" <if condition="input('request.disable') neq '' && input('request.disable') eq 0">selected</if>>否</option>
        </select>

        热门：
        <select class="form-control" name="ishot">
            <option value="">全部</option>
            <option value="1" <if condition="input('request.ishot') neq '' && input('request.ishot') eq 1">selected</if>>是</option>
            <option value="0" <if condition="input('request.ishot') neq '' && input('request.ishot') eq 0">selected</if>>否</option>
        </select>

        超管：
        <select class="form-control" name="issuper">
            <option value="">全部</option>
            <option value="1" <if condition="input('request.issuper') neq '' && input('request.issuper') eq 1">selected</if>>是</option>
            <option value="0" <if condition="input('request.issuper') neq '' && input('request.issuper') eq 0">selected</if>>否</option>
        </select>
        设备来源：
        <select class="form-control" name="source">
            <option value="">全部</option>
            <option value="pc" <if condition="input('request.source') neq '' && input('request.source') eq 'pc'">selected</if>>PC</option>
            <option value="android" <if condition="input('request.source') neq '' && input('request.source') eq 'android'">selected</if>>安卓APP</option>
            <option value="ios" <if condition="input('request.source') neq '' && input('request.source') eq 'ios'">selected</if>>苹果APP</option>
        </select>

        提交时间：
        <input class="form-control js-bootstrap-date" name="start_time" id="start_time" autocomplete="off" value="{:input('request.start_time')}" aria-invalid="false" style="width: 110px;"> -
        <input class="form-control js-bootstrap-date" name="end_time" id="end_time" autocomplete='off' value="{:input('request.end_time')}" aria-invalid="false" style="width: 110px;">

        用户ID：
        <input class="form-control" type="text" name="uid" style="width: 200px;" value="{:input('request.uid')}"
               placeholder="请输入用户ID或靓号">
        关键字：
        <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}"
               placeholder="用户名/昵称">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('user/adminIndex/index')}">清空</a>
        <br>
        <br>
        用户数：{$nums}  (根据条件统计)
    </form>
    <form method="post" class="js-ajax-form">
        <div class="table-actions">
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('user/adminIndex/setzombiepall',array('iszombiep'=>1))}"
                    data-subcheck="true" data-msg="您确定要进行此操作吗？">批量设置为僵尸粉
            </button>
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('user/adminIndex/setzombiepall',array('iszombiep'=>0))}"
                    data-subcheck="true" data-msg="您确定要进行此操作吗？">批量取消僵尸粉
            </button>

            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('user/adminIndex/setzombieall',array('iszombie'=>1))}" data-msg="您确定要进行此操作吗？">一键开启僵尸粉
            </button>
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('user/adminIndex/setzombieall',array('iszombie'=>0))}" data-msg="您确定要进行此操作吗？">一键关闭僵尸粉
            </button>
        </div>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>ID</th>
                <th>国家/地区</th>
                <th>{:lang('USERNAME')}</th>
                <th>{:lang('NICENAME')}</th>
                <th>{:lang('AVATAR')}</th>
                <th>手机</th>
                <th>{$name_coin}余额</th>
                <th>累计消费{$name_coin}</th>
                <th>{$name_votes}余额</th>
                <th>累计{$name_votes}</th>
                <th>人民币余额</th>
                <th>累计收入人民币</th>
                <th>人民币累计消费</th>
                <th>邀请码</th>
                <th>注册设备</th>
                <th>广告视频发布者</th>
                <th>{:lang('REGISTRATION_TIME')}</th>
                <th>{:lang('LAST_LOGIN_TIME')}</th>
                <th>{:lang('LAST_LOGIN_IP')}</th>
                <th>{:lang('STATUS')}</th>
                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $user_statuses=array("0"=>lang('USER_STATUS_BLOCKED'),"1"=>lang('USER_STATUS_ACTIVATED'),"2"=>lang('USER_STATUS_UNVERIFIED'),"3"=>"已禁用");$isAd=array("0"=>"否","1"=>"是");
            </php>
            <foreach name="list" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}">
                    </td>
                    <td>{$vo.id}</td>
                    <td><if condition="$vo['login_type'] eq 'phone'">{$vo.country_name}<else />--</if></td>
                    <td>{$vo['user_login']?$vo['user_login']:($vo['mobile']?$vo['mobile']:lang('THIRD_PARTY_USER'))}
                    </td>
                    <td>{$vo['user_nickname']?$vo['user_nickname']:lang('NOT_FILLED')}</td>
                    <td><img width="25" height="25" src="{$vo['avatar']}"/></td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.coin}</td>
                    <td>{$vo.consumption}</td>
                    <td>{$vo.votes}</td>
                    <td>{$vo.votestotal}</td>
                    <td>{$vo.balance}</td>
                    <td>{$vo.balance_total}</td>
                    <td>{$vo.balance_consumption}</td>
                    <td>{$vo.code}</td>
                    <td>{$vo.source}</td>
                    <td>{$isAd[$vo['is_ad']]}</td>
                    <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                    <td><if condition="$vo['last_login_time'] gt 0">{:date('Y-m-d H:i:s',$vo['last_login_time'])}<else />--</if></td>
                    <td>{$vo.last_login_ip}</td>
                    <td>
                        <if condition="$vo['user_status'] eq '3'">
                            已注销
                            <else />



                            <if condition="$vo.user_status eq 0">
                                <span class="label label-danger">{$user_statuses[0]}</span>
                                <elseif condition="$vo.user_status eq 1 && $vo.end_bantime gt $nowtime">
                                    <span class="label label-danger">{$user_statuses[3]}</span>
                                    <br />
                                    截止到:{:date('Y-m-d',$vo['end_bantime'])}
                                    <else/>
                                    <span class="label label-success">{$user_statuses[1]}</span>
                            </if>

                        </if>

                    </td>
                    <td>
                        <if condition="$vo['user_status'] eq '3'">
                            <!-- 已注销 -->



                            <else />
                            <!-- 未注销 -->

                            <if condition="$vo.user_status eq 0">
                                <a class="btn btn-xs btn-success js-ajax-dialog-btn"
                                   href="{:url('adminIndex/cancelban',array('id'=>$vo['id']))}"
                                   data-msg="{:lang('ACTIVATE_USER_CONFIRM_MESSAGE')}">{:lang('ACTIVATE_USER')}</a>
                                <!-- 启用 -->
                                <else/>

                                <if condition="$vo.end_bantime gt $nowtime">
                                    <a class="btn btn-xs btn-success js-ajax-dialog-btn"
                                       href="{:url('adminIndex/cancelban',array('id'=>$vo['id']))}"
                                       data-msg="{:lang('ACTIVATE_USER_CONFIRM_MESSAGE')}">{:lang('ACTIVATE_USER')}</a>
                                    <!-- 启用 -->
                                    <else/>
                                    <!--  -->
                                    <a class="btn btn-xs btn-warning"
                                       href="javascript:void(0);"
                                       onclick="showlayer({$vo['id']})">禁用</a>
                                </if>

                                <a class="btn btn-xs btn-warning js-ajax-dialog-btn"
                                   href="{:url('adminIndex/ban',array('id'=>$vo['id']))}"
                                   data-msg="您确定要拉黑此用户吗？">拉黑</a>
                            </if>

                            <if condition="$vo['live_ban'] eq '1'">
                                <a class="btn btn-xs btn-warning js-ajax-dialog-btn"
                                   href="{:url('adminIndex/cancelLiveBan',array('id'=>$vo['id']))}"
                                   data-msg="您确定要将此用户直播间解封吗？">解封直播</a>
                            </if>

                            <if condition="$vo.issuper eq '1'">
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setsuper',array('id'=>$vo['id'],'issuper'=>0))}">取消超管</a>
                                <else/>
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setsuper',array('id'=>$vo['id'],'issuper'=>1))}">设置超管</a>
                            </if>

                            <if condition="$vo.ishot eq '1'">
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/sethot',array('id'=>$vo['id'],'ishot'=>0))}">取消热门</a>
                                <else/>
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/sethot',array('id'=>$vo['id'],'ishot'=>1))}">热门</a>
                            </if>

                            <if condition="$vo.isrecommend eq '1'">
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setrecommend',array('id'=>$vo['id'],'isrecommend'=>0))}">取消推荐</a>
                                <else/>
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setrecommend',array('id'=>$vo['id'],'isrecommend'=>1))}">推荐</a>
                            </if>

                            <if condition="$vo.iszombie eq '1'">
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setzombie',array('id'=>$vo['id'],'iszombie'=>0))}">关闭僵尸粉</a>
                                <else/>
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setzombie',array('id'=>$vo['id'],'iszombie'=>1))}">开启僵尸粉</a>
                            </if>

                            <if condition="$vo.iszombiep eq '1'">
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setzombiep',array('id'=>$vo['id'],'iszombiep'=>0))}">取消设置僵尸粉</a>
                                <else/>
                                <a class="btn btn-xs btn-info js-ajax-dialog-btn"
                                   href="{:url('adminIndex/setzombiep',array('id'=>$vo['id'],'iszombiep'=>1))}">设置为僵尸粉</a>
                            </if>

                        </if>


                        <a class="btn btn-xs btn-primary" href='{:url("adminIndex/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('adminIndex/del',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>

<div id="pop">
    <div class="wrap" style="padding-bottom:40px;">
        <form method="post" class="form-horizontal margin-top-20">
            <div class="form-group">
                <label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>禁用截止日期</label>
                <div class="col-md-6 col-sm-10">
                    <input class="form-control js-bootstrap-date" name="ban_long" contenteditable="off" id="ban_long" value="" aria-invalid="false">
                </div>
            </div>

            <div class="form-group">
                <label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>禁用原因</label>
                <div class="col-md-6 col-sm-10">
                    <textarea class="form-control" id="ban_reason" name="ban_reason" placeholder="200字以内"></textarea>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <a href="javascript:void(0)" class="btn btn-primary" onclick="xiajia_submit()">禁用</a>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/js/laydate/laydate.js"></script>
<script>
    Wind.use('layer');
    var clickuid='0';
    function showlayer(id){
        clickuid=id;
        layer.open({
            type: 1,
            title: '禁用',
            shadeClose: true,
            shade: 0.8,
            area: ['800px', '300px'],
            content: $('#pop'),
            success:function(){
                laydate.render({
                    elem: '#ban_long',//指定元素
                    trigger: 'click'
                });
            }
        });
    }


    var xiajia_status=0;
    function xiajia_submit(){
        var ban_long=$("#ban_long").val();
        var reason=$("#ban_reason").val();

        if(ban_long==''){
            layer.msg("请选择禁用截止日期");
            return;
        }

        if(reason==''){
            layer.msg("请填写禁用原因");
            return;
        }

        if(reason.length>200){
            layer.msg("禁用原因必须在200字以内");
            return;
        }

        if(xiajia_status==1){
            return;
        }
        xiajia_status=1;
        $.ajax({
            url: '{:url('user/adminIndex/setBan')}',
            type: 'POST',
            dataType: 'json',
            data: {id:clickuid,reason: reason,ban_long:ban_long},
        success:function(data){
            var code=data.code;
            if(code==0){
                layer.msg(data.msg);
                return !1;
            }

            xiajia_status=0;

            layer.msg("操作成功",{},function(){
                //layer.closeAll();
                clickuid=0;
                $("#ban_long").val("");
                $("#ban_reason").attr("value","");
                layer.closeAll();
                reloadPage(window);
            });
        },
        error:function(e){
        }
    });

    }
</script>
</body>
</html>